import Util from './util';

const globalConfig = {};

globalConfig.appId = '5b0785dec53140e1a90ec2ba37a737b4'; // 声网AppId

// 根据环境获取域名
globalConfig.getBaseUrl = function () {
  const VUE_APP_TITLE = process.env.VUE_APP_TITLE || '';
  let baseUrl = '';

  switch (VUE_APP_TITLE) {
    case 'uat': // 验收uat
      baseUrl = process.env.NODE_ENV == 'production' ? '/new-hospital' : '/uat';
      break;
    default:
      baseUrl = process.env.NODE_ENV == 'production' ? '' : '/dev';
  }
  return baseUrl;
};

// 当前医院
globalConfig.hospitalName = '成都温江大医睐互联网医院';
globalConfig.full_title = '成都温江大医睐互联网医院';
// 当前医院的socket
globalConfig.socketName = (() => {
  let devSocket = 'hospital-test.yixianmedical.com';
  const liveSocket = 'www.daylaiyy.com';
  // TODO: 本地开发环境待删除
  devSocket = liveSocket;

  if (process.env.VUE_APP_TITLE == 'uat') {
    return `${liveSocket}/new-hospital`;
  }
  return process.env.NODE_ENV == 'development' ? devSocket : liveSocket;
})();
// 远程会诊的socket
globalConfig.remoteSocket = 'www.daylaiyy.com/consultation';

// 当前医院的导航底部文本
globalConfig.bottomName = '广州市诺祥康医药科技有限公司';
globalConfig.bottomNumber = '粤ICP备19127177号';

// 当前医院关键字
globalConfig.hospitalKey = 'scdyl';
const sichuan = ['genzi', 'yhsx', 'yhljj', 'fuxing'];
console.log(`【${globalConfig.hospitalKey}-${process.env.VUE_APP_TITLE || process.env.NODE_ENV}】-【${globalConfig.socketName}】`);

// 判断医院平台
globalConfig.platform = function (hospitalKey) {
  return hospitalKey && hospitalKey.includes(globalConfig.hospitalKey);
};

// 判断医保(珠海、廉江)
globalConfig.isYiBao = globalConfig.platform(['zh', 'lj']);
// 判断等保
globalConfig.isSave = globalConfig.platform(['scdyl', 'nuanhe', ...sichuan]);
// 判断自主开方
if (process.env.VUE_APP_TITLE == 'test' || process.env.NODE_ENV == 'development') {
  // 测试环境(dyl可测试自主开方)
  globalConfig.isAuto = !globalConfig.platform(['nuanhe', 'yihan']);
} else {
  globalConfig.isAuto = !globalConfig.platform(['nuanhe', 'yihan', 'scdyl', ...sichuan]);
}
// 判断益汉自主开方
globalConfig.isAutoByYihan = globalConfig.platform(['yihan']);
// 判断医生角色CA认证
globalConfig.isCa = globalConfig.platform(['scdyl', ...sichuan]);
// 判断管制禁用药品
globalConfig.isMental = globalConfig.platform(['scdyl', ...sichuan]);
// 判断新病历引用
globalConfig.isNewCase = globalConfig.platform(['scdyl', ...sichuan]);
// 是否需要远程会诊+远程影像
globalConfig.isEntity = globalConfig.platform(['scdyl', ...sichuan]);
globalConfig.interfaceUrl = 'https://dbdev.dottmed.com/portal.html#/autologin?username=17724289391&password=gd2h2020';
// trtc or agora
globalConfig.isTrtc = globalConfig.platform(['yihan']);

globalConfig.pager = {
  total: 0,
  current: 1,
  size: 20,
  sizes: [20, 50, 100],
};

export default globalConfig;
